home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / edit / jed207.lha / src / jed.lha / editcommands.c < prev    next >
C/C++ Source or Header  |  1993-01-09  |  15KB  |  665 lines

  1.  
  2. /*
  3.  * EDITCOMMANDS.C
  4.  * (c) 1992-3 J.Harper
  5.  */
  6.  
  7. #include "jed.h"
  8. #include "jed_protos.h"
  9.  
  10. Prototype   VALUE * cmd_split        (LONG, VALUE *);
  11. Prototype   VALUE * cmd_join        (LONG, VALUE *);
  12. Prototype   VALUE * cmd_insert        (LONG, VALUE *);
  13. Prototype   VALUE * cmd_delete        (LONG, VALUE *);
  14. Prototype   VALUE * cmd_copy        (LONG, VALUE *);
  15. Prototype   VALUE * cmd_cut        (LONG, VALUE *);
  16. Prototype   VALUE * cmd_block        (LONG, VALUE *);
  17. Prototype   VALUE * cmd_clear        (LONG, VALUE *);
  18. Prototype   VALUE * cmd_undo        (LONG, VALUE *);
  19. Prototype   VALUE * cmd_extract        (LONG, VALUE *);
  20. Prototype   VALUE * cmd_poke        (LONG, VALUE *);
  21. Prototype   VALUE * cmd_toupper        (LONG, VALUE *);
  22. Prototype   VALUE * cmd_tolower        (LONG, VALUE *);
  23. Prototype   VALUE * cmd_changecase  (LONG, VALUE *);
  24. Local        UBYTE   changecase        (UBYTE);
  25. Prototype   VALUE * cmd_isalpha        (LONG, VALUE *);
  26. Prototype   VALUE * cmd_isdigit        (LONG, VALUE *);
  27. Prototype   VALUE * cmd_isalnum        (LONG, VALUE *);
  28. Prototype   VALUE * cmd_isspace        (LONG, VALUE *);
  29.  
  30. VALUE *
  31. cmd_split(LONG argc, VALUE *argv)
  32. {
  33.     VW *vw = CurrVW;
  34.     TX *tx = vw->vw_Tx;
  35.     BOOL rc = FALSE;
  36.     setrefresh(RFF_ALLFROM, vw->vw_CursorPos.pos_Col, vw->vw_CursorPos.pos_Line);
  37.     if(padcursor())
  38.     {
  39.     if(splitline())
  40.     {
  41.         if(tx->tx_Lines[vw->vw_CursorPos.pos_Line].ln_Strlen == 1)
  42.         {
  43.         if(vw->vw_Prefs.prf_AutoIndent)
  44.             vw->vw_CursorPos.pos_Col = (WORD)spclen(tx->tx_Lines[vw->vw_CursorPos.pos_Line - 1].ln_Line);
  45.         else
  46.             vw->vw_CursorPos.pos_Col = vw->vw_Prefs.prf_LeftMargin;
  47.         }
  48.         resyncxy();
  49.         tx->tx_Changes++;
  50.         rc = TRUE;
  51.     }
  52.     }
  53.     setnumres(rc);
  54.     return(&RES);
  55. }
  56.  
  57. VALUE *
  58. cmd_join(LONG argc, VALUE *argv)
  59. {
  60.     VW *vw = CurrVW;
  61.     TX *tx = vw->vw_Tx;
  62.     BOOL rc = FALSE;
  63.     if(vw->vw_CursorPos.pos_Line < (tx->tx_NumLines - 1))
  64.     {
  65.     setrefresh(RFF_ALLFROM, vw->vw_CursorPos.pos_Col, vw->vw_CursorPos.pos_Line);
  66.     if(padcursor())
  67.     {
  68.         if(joinlines())
  69.         {
  70.         resyncx();
  71.         tx->tx_Changes++;
  72.         rc = TRUE;
  73.         }
  74.     }
  75.     }
  76.     setnumres(rc);
  77.     return(&RES);
  78. }
  79.  
  80. /*
  81.  * Section types or,
  82.  * s `string'
  83.  * a ascii#
  84.  * f `file'
  85.  * cb unit#
  86.  */
  87. VALUE *
  88. cmd_insert(LONG argc, VALUE *argv)
  89. {
  90.     if(TPLATE2(VTF_STRING, VTF_ANY))
  91.     {
  92.     VW *vw = CurrVW;
  93.     TX *tx = vw->vw_Tx;
  94.     STRPTR arg = ARG1.val_Value.String;
  95.     LONG rc;
  96.  
  97.     if(padcursor())
  98.     {
  99.         POS oldcursor = vw->vw_CursorPos;
  100.         switch(tolower(*arg))
  101.         {
  102.         case 's':
  103.             if(!(rc = insertstring(ARG2.val_Value.String, vw->vw_Prefs.prf_TabSize)))
  104.             settitle(NoMemMsg);
  105.             resyncxy();
  106.             tx->tx_Changes++;
  107.             break;
  108.         case 'a':
  109.             UBYTE string[2];
  110.             string[0] = (UBYTE)ARG2.val_Value.Number;
  111.             string[1] = 0;
  112.             if(!(rc = insertstring(string, vw->vw_Prefs.prf_TabSize)))
  113.             settitle(NoMemMsg);
  114.             resyncx();
  115.             tx->tx_Changes++;
  116.             break;
  117.         case 'f':
  118.             STRPTR file = squirrelfile(ARG2.val_Value.String);
  119.             if(file)
  120.             {
  121.             if(!(rc = insertstring(file, vw->vw_Prefs.prf_DiskTab)))
  122.                 settitle(NoMemMsg);
  123.             resyncxy();
  124.             tx->tx_Changes++;
  125.             freestring(file);
  126.             }
  127.             else
  128.             rc = FALSE;
  129.             break;
  130.         case 'c':
  131.             if(arg[1] == 'b')
  132.             {
  133.             LONG unit = ((ARG2.val_Type == VTF_NUMBER) ? ARG2.val_Value.Number : 0);
  134.             STRPTR text = readclip(unit);
  135.             if(text)
  136.             {
  137.                 if(!(rc = insertstring(text, vw->vw_Prefs.prf_DiskTab)))
  138.                 settitle(NoMemMsg);
  139.                 resyncxy();
  140.                 tx->tx_Changes++;
  141.                 FreeVec(text);
  142.             }
  143.             else
  144.                 rc = FALSE;
  145.             }
  146.             else
  147.             rc = FALSE;
  148.             break;
  149.         default:
  150.             if(rc = insertsection(arg))
  151.             tx->tx_Changes++;
  152.             resyncxy();
  153.             break;
  154.         }
  155.         vw->vw_AutoMark = oldcursor;
  156.     }
  157.     else
  158.         rc = FALSE;
  159.     setnumres(rc);
  160.     }
  161.     return(&RES);
  162. }
  163.  
  164. VALUE *
  165. cmd_delete(LONG argc, VALUE *argv)
  166. {
  167.     if(TPLATE1(VTF_STRING))
  168.     {
  169.     BOOL rc = FALSE;
  170.     if(padcursor())
  171.     {
  172.         VW *vw = CurrVW;
  173.         POS endpos;
  174.         POS oldcurs = vw->vw_CursorPos;
  175.         if(getsection(ARG1.val_Value.String, &endpos))
  176.         {
  177.         deletesection(&endpos);
  178.         vw->vw_Tx->tx_Changes++;
  179.         rc = TRUE;
  180.         }
  181.         else
  182.         vw->vw_CursorPos = oldcurs;
  183.     }
  184.     setnumres(rc);
  185.     }
  186.     return(&RES);
  187. }
  188.  
  189. /*
  190.  * (copy `sectType' unit#)
  191.  * copies text onto the clipboard unit#
  192.  */
  193. VALUE *
  194. cmd_copy(LONG argc, VALUE *argv)
  195. {
  196.     if(TPLATE2(VTF_STRING, VTF_ANY))
  197.     {
  198.     BOOL rc = FALSE;
  199.     if(padcursor())
  200.     {
  201.         VW *vw = CurrVW;
  202.         POS endpos, oldcurs = vw->vw_CursorPos;
  203.         if(getsection(ARG1.val_Value.String, &endpos))
  204.         rc = writeclip((ARG2.val_Type == VTF_NUMBER) ? ARG2.val_Value.Number : 0, &vw->vw_CursorPos, &endpos);
  205.         vw->vw_CursorPos = oldcurs;
  206.     }
  207.     setnumres(rc);
  208.     }
  209.     return(&RES);
  210. }
  211.  
  212. /*
  213.  * (cut `sectType' unit#)
  214.  * copies text to the clipboard then deletes it from the file.
  215.  */
  216. VALUE *
  217. cmd_cut(LONG argc, VALUE *argv)
  218. {
  219.     if(TPLATE2(VTF_STRING, VTF_ANY))
  220.     {
  221.     BOOL rc = FALSE;
  222.     if(padcursor())
  223.     {
  224.         VW *vw = CurrVW;
  225.         POS startpos, endpos;
  226.         startpos = vw->vw_CursorPos;
  227.         if(getsection(ARG1.val_Value.String, &endpos))
  228.         {
  229.         POS startstore = vw->vw_CursorPos;
  230.         vw->vw_CursorPos = startpos;
  231.         startpos = startstore;
  232.         if(writeclip((ARG2.val_Type == VTF_NUMBER) ? ARG2.val_Value.Number : 0, &startpos, &endpos))
  233.         {
  234.             vw->vw_CursorPos = startstore;
  235.             deletesection(&endpos);
  236.             vw->vw_Tx->tx_Changes++;
  237.             rc = TRUE;
  238.         }
  239.         }
  240.     }
  241.     setnumres(rc);
  242.     }
  243.     return(&RES);
  244. }
  245.  
  246. /*
  247.  * (block `type')
  248.  *
  249.  * sets block marks, either uses standard section type or,
  250.  *    t   -    toggle between, set start, set end, kill block
  251.  *    s   -    set start
  252.  *    e   -    set end
  253.  *    k   -    kill block
  254.  */
  255. VALUE *
  256. cmd_block(LONG argc, VALUE *argv)
  257. {
  258.     if(TPLATE1(VTF_STRING))
  259.     {
  260.     VW *vw = CurrVW;
  261.     STRPTR arg = ARG1.val_Value.String;
  262.  
  263.     if(!stricmp(arg, "t"))
  264.     {
  265.         switch(vw->vw_BlockStatus)
  266.         {
  267.         case 0:
  268.             vw->vw_BlockStatus = -1;
  269.             setblockrefresh();
  270.             break;
  271.         case 1:
  272.             vw->vw_Block[1] = vw->vw_CursorPos;
  273.             vw->vw_BlockStatus = 0;
  274.             orderblock();
  275.             setblockrefresh();
  276.             break;
  277.         case 2:
  278.             vw->vw_Block[0] = vw->vw_CursorPos;
  279.             vw->vw_BlockStatus = 0;
  280.             orderblock();
  281.             setblockrefresh();
  282.             break;
  283.         case -1:
  284.             vw->vw_Block[0] = vw->vw_CursorPos;
  285.             vw->vw_BlockStatus = 1;
  286.             break;
  287.         }
  288.     }
  289.     else if(!stricmp(arg, "s"))
  290.     {
  291.         switch(vw->vw_BlockStatus)
  292.         {
  293.         case 0:
  294.             setblockrefresh();
  295.             vw->vw_Block[0] = vw->vw_CursorPos;
  296.             orderblock();
  297.             setblockrefresh();
  298.             break;
  299.         case 2:
  300.             vw->vw_Block[0] = vw->vw_CursorPos;
  301.             vw->vw_BlockStatus = 0;
  302.             orderblock();
  303.             setblockrefresh();
  304.             break;
  305.         case -1:
  306.             vw->vw_Block[0] = vw->vw_CursorPos;
  307.             vw->vw_BlockStatus = 1;
  308.             break;
  309.         }
  310.     }
  311.     else if(!stricmp(arg, "e"))
  312.     {
  313.         switch(vw->vw_BlockStatus)
  314.         {
  315.         case 0:
  316.             setblockrefresh();
  317.             vw->vw_Block[1] = vw->vw_CursorPos;
  318.             orderblock();
  319.             setblockrefresh();
  320.             break;
  321.         case 1:
  322.             vw->vw_Block[1] = vw->vw_CursorPos;
  323.             vw->vw_BlockStatus = 0;
  324.             orderblock();
  325.             setblockrefresh();
  326.             break;
  327.         case -1:
  328.             vw->vw_Block[1] = vw->vw_CursorPos;
  329.             vw->vw_BlockStatus = 2;
  330.             break;
  331.         }
  332.     }
  333.     else if(!stricmp(arg, "k"))
  334.     {
  335.         if(!vw->vw_BlockStatus)
  336.         {
  337.         vw->vw_BlockStatus = -1;
  338.         setblockrefresh();
  339.         }
  340.     }
  341.     else
  342.     {
  343.         POS cursorsafe = vw->vw_CursorPos;
  344.         if(!vw->vw_BlockStatus)
  345.         setblockrefresh();
  346.         if(getsection(arg, &vw->vw_Block[1]))
  347.         {
  348.         vw->vw_Block[0] = vw->vw_CursorPos;
  349.         vw->vw_BlockStatus = 0;
  350.         }
  351.         else
  352.         vw->vw_BlockStatus = -1;
  353.         vw->vw_CursorPos = cursorsafe;
  354.         setblockrefresh();
  355.     }
  356.     setnumres(TRUE);
  357.     }
  358.     return(&RES);
  359. }
  360.  
  361. VALUE *
  362. cmd_clear(LONG argc, VALUE *argv)
  363. {
  364.     VW *vw = CurrVW;
  365.     TX *tx = vw->vw_Tx;
  366.     BOOL rc = FALSE;
  367.     if((!tx->tx_Changes) || (ezreq("OK to lose %ld changes\nto file %s", "Yeah|Cancel", tx->tx_Changes, tx->tx_TitleName)))
  368.     {
  369.     clearlinelist(tx);
  370.     freestring(tx->tx_TitleName);
  371.     freestring(tx->tx_FileName);
  372.     tx->tx_FileName = savestring("");
  373.     tx->tx_TitleName = savestring("Untitled");
  374.     tx->tx_Changes = 0;
  375.     resetallviews(tx);
  376.     resetslptxtitles(tx);
  377.     if(tx->tx_ResetPrefs)
  378.         getdefprefs(tx);
  379.     rc = TRUE;
  380.     }
  381.     setnumres(rc);
  382.     return(&RES);
  383. }
  384.  
  385. /*
  386.  * (undo `type')
  387.  * type,
  388.  *  l    --  undo line only if on the line in undo buffer
  389.  *  L    --  undo line even if buffer and cursor pos don't match
  390.  */
  391. VALUE *
  392. cmd_undo(LONG argc, VALUE *argv)
  393. {
  394.     if(TPLATE1(VTF_STRING))
  395.     {
  396.     VW *vw = CurrVW;
  397.     TX *tx = vw->vw_Tx;
  398.     BOOL rc = FALSE;
  399.     switch(*(ARG1.val_Value.String))
  400.     {
  401.         case 'l':
  402.         if(vw->vw_LineUndo.line != vw->vw_CursorPos.pos_Line)
  403.         {
  404.             settitle("error: undo buffer not from this line");
  405.             goto lu_end;
  406.         }
  407.         /* fall through */
  408.         case 'L':
  409.         if(vw->vw_LineUndo.line < tx->tx_NumLines)
  410.         {
  411.             if(vw->vw_LineUndo.text)
  412.             {
  413.             LINE *line = tx->tx_Lines + vw->vw_LineUndo.line;
  414.             WORD nllen = strlen(vw->vw_LineUndo.text);
  415.             WORD diff = nllen - (line->ln_Strlen - 1);
  416.             STRPTR tln = line->ln_Line;
  417.             LONG tchg = tx->tx_Changes;
  418.             line->ln_Line = vw->vw_LineUndo.text;
  419.             line->ln_Strlen = nllen + 1;
  420.             tx->tx_Changes = vw->vw_LineUndo.changes;
  421.             vw->vw_LineUndo.text = tln;
  422.             vw->vw_LineUndo.changes = tchg;
  423.             if(diff < 0)
  424.                 keeppossubx(-diff);
  425.             setrefresh(RFF_LINEFROM, 0, vw->vw_LineUndo.line);
  426.             resyncx();
  427.             rc = TRUE;
  428.             }
  429.             else
  430.             settitle("error: nothing in undo buffer");
  431.         }
  432. lu_end:        break;
  433.         default:
  434.         settitle(BadArgMsg);
  435.         break;
  436.     }
  437.     setnumres(rc);
  438.     }
  439.     return(&RES);
  440. }
  441.  
  442. /*
  443.  * (extract `sectionType')
  444.  */
  445. VALUE *
  446. cmd_extract(LONG argc, VALUE *argv)
  447. {
  448.     if(TPLATE1(VTF_STRING))
  449.     {
  450.     VW *vw = CurrVW;
  451.     POS oldcurs = vw->vw_CursorPos;
  452.     POS endpos;
  453.     if(getsection(ARG1.val_Value.String, &endpos))
  454.     {
  455.         LINE *line = vw->vw_Tx->tx_Lines + vw->vw_CursorPos.pos_Line;
  456.         STRPTR text;
  457.         LONG length = sectionlength(&vw->vw_CursorPos, &endpos) + 1;
  458.         if(text = AllocVec(length, 0L))
  459.         {
  460.         copysection(&vw->vw_CursorPos, &endpos, text);
  461.         text[length] = 0;
  462.         setstrres(text);
  463.         }
  464.         else
  465.         settitle(NoMemMsg);
  466.     }
  467.     vw->vw_CursorPos = oldcurs;
  468.     }
  469.     return(&RES);
  470. }
  471.  
  472. /*
  473.  * (poke asciival)
  474.  */
  475. VALUE *
  476. cmd_poke(LONG argc, VALUE *argv)
  477. {
  478.     if(TPLATE1(VTF_NUMBER))
  479.     {
  480.     VW *vw = CurrVW;
  481.     BOOL rc = FALSE;
  482.     if(padcursor())
  483.     {
  484.         LINE *line = vw->vw_Tx->tx_Lines + vw->vw_CursorPos.pos_Line;
  485.         if(vw->vw_CursorPos.pos_Col == (line->ln_Strlen - 1))
  486.         {
  487.         STRPTR newline = AllocVec(line->ln_Strlen + 1, 0);
  488.         if(newline)
  489.         {
  490.             memcpy(newline, line->ln_Line, line->ln_Strlen - 1);
  491.             newline[vw->vw_CursorPos.pos_Col] = (UBYTE)ARG1.val_Value.Number;
  492.             newline[vw->vw_CursorPos.pos_Col + 1] = 0;
  493.             stuffline(newline, vw->vw_CursorPos.pos_Line);
  494.             rc = TRUE;
  495.         }
  496.         else
  497.             settitle(NoMemMsg);
  498.         }
  499.         else
  500.         {
  501.         line->ln_Line[vw->vw_CursorPos.pos_Col] = (UBYTE)ARG1.val_Value.Number;
  502.         rc = TRUE;
  503.         }
  504.     }
  505.     vw->vw_Tx->tx_Changes++;
  506.     setrefresh(RFF_LINEFROM, vw->vw_CursorPos.pos_Col, vw->vw_CursorPos.pos_Line);
  507.     setnumres(rc);
  508.     }
  509.     return(&RES);
  510. }
  511.  
  512. /*
  513.  * (toupper `section')
  514.  * (tolower `section')
  515.  * (changecase `section')
  516.  */
  517. VALUE *
  518. cmd_toupper(LONG argc, VALUE *argv)
  519. {
  520.     if(TPLATE1(VTF_STRING))
  521.     {
  522.     VW *vw = CurrVW;
  523.     POS oldcurs = vw->vw_CursorPos;
  524.     POS endpos;
  525.     BOOL rc = FALSE;
  526.     if(getsection(ARG1.val_Value.String, &endpos))
  527.     {
  528.         TX *tx = vw->vw_Tx;
  529.         LINE *line = tx->tx_Lines + vw->vw_CursorPos.pos_Line;
  530.  
  531.         setrefresh((endpos.pos_Line > vw->vw_CursorPos.pos_Line) ? RFF_ALLFROM : RFF_LINEFROM, vw->vw_CursorPos.pos_Col, vw->vw_CursorPos.pos_Line);
  532.         while(vw->vw_CursorPos.pos_Line < endpos.pos_Line)
  533.         {
  534.         while(vw->vw_CursorPos.pos_Col < line->ln_Strlen)
  535.             line->ln_Line[vw->vw_CursorPos.pos_Col] = toupper(line->ln_Line[vw->vw_CursorPos.pos_Col++]);
  536.         vw->vw_CursorPos.pos_Col = 0;
  537.         vw->vw_CursorPos.pos_Line++;
  538.         line++;
  539.         }
  540.         while(vw->vw_CursorPos.pos_Col < endpos.pos_Col)
  541.         line->ln_Line[vw->vw_CursorPos.pos_Col] = toupper(line->ln_Line[vw->vw_CursorPos.pos_Col++]);
  542.         vw->vw_CursorPos = oldcurs;
  543.         rc = TRUE;
  544.     }
  545.     setnumres(rc);
  546.     }
  547.     return(&RES);
  548. }
  549.  
  550. VALUE *
  551. cmd_tolower(LONG argc, VALUE *argv)
  552. {
  553.     if(TPLATE1(VTF_STRING))
  554.     {
  555.     VW *vw = CurrVW;
  556.     POS oldcurs = vw->vw_CursorPos;
  557.     POS endpos;
  558.     BOOL rc = FALSE;
  559.     if(getsection(ARG1.val_Value.String, &endpos))
  560.     {
  561.         TX *tx = vw->vw_Tx;
  562.         LINE *line = tx->tx_Lines + vw->vw_CursorPos.pos_Line;
  563.  
  564.         setrefresh((endpos.pos_Line > vw->vw_CursorPos.pos_Line) ? RFF_ALLFROM : RFF_LINEFROM, vw->vw_CursorPos.pos_Col, vw->vw_CursorPos.pos_Line);
  565.         while(vw->vw_CursorPos.pos_Line < endpos.pos_Line)
  566.         {
  567.         while(vw->vw_CursorPos.pos_Col < line->ln_Strlen)
  568.             line->ln_Line[vw->vw_CursorPos.pos_Col] = tolower(line->ln_Line[vw->vw_CursorPos.pos_Col++]);
  569.         vw->vw_CursorPos.pos_Col = 0;
  570.         vw->vw_CursorPos.pos_Line++;
  571.         line++;
  572.         }
  573.         while(vw->vw_CursorPos.pos_Col < endpos.pos_Col)
  574.         line->ln_Line[vw->vw_CursorPos.pos_Col] = tolower(line->ln_Line[vw->vw_CursorPos.pos_Col++]);
  575.         vw->vw_CursorPos = oldcurs;
  576.         rc = TRUE;
  577.     }
  578.     setnumres(rc);
  579.     }
  580.     return(&RES);
  581. }
  582.  
  583. VALUE *
  584. cmd_changecase(LONG argc, VALUE *argv)
  585. {
  586.     if(TPLATE1(VTF_STRING))
  587.     {
  588.     VW *vw = CurrVW;
  589.     POS oldcurs = vw->vw_CursorPos;
  590.     POS endpos;
  591.     BOOL rc = FALSE;
  592.     if(getsection(ARG1.val_Value.String, &endpos))
  593.     {
  594.         TX *tx = vw->vw_Tx;
  595.         LINE *line = tx->tx_Lines + vw->vw_CursorPos.pos_Line;
  596.  
  597.         setrefresh((endpos.pos_Line > vw->vw_CursorPos.pos_Line) ? RFF_ALLFROM : RFF_LINEFROM, vw->vw_CursorPos.pos_Col, vw->vw_CursorPos.pos_Line);
  598.         while(vw->vw_CursorPos.pos_Line < endpos.pos_Line)
  599.         {
  600.         while(vw->vw_CursorPos.pos_Col < line->ln_Strlen)
  601.             line->ln_Line[vw->vw_CursorPos.pos_Col] = changecase(line->ln_Line[vw->vw_CursorPos.pos_Col++]);
  602.         vw->vw_CursorPos.pos_Col = 0;
  603.         vw->vw_CursorPos.pos_Line++;
  604.         line++;
  605.         }
  606.         while(vw->vw_CursorPos.pos_Col < endpos.pos_Col)
  607.         line->ln_Line[vw->vw_CursorPos.pos_Col] = changecase(line->ln_Line[vw->vw_CursorPos.pos_Col++]);
  608.         vw->vw_CursorPos = oldcurs;
  609.         rc = TRUE;
  610.     }
  611.     setnumres(rc);
  612.     }
  613.     return(&RES);
  614. }
  615.  
  616. Local UBYTE
  617. changecase(UBYTE c)
  618. {
  619.     if(isupper(c))
  620.     return(tolower(c));
  621.     else if(islower(c))
  622.     return(toupper(c));
  623.     return(c);
  624. }
  625.  
  626. VALUE *
  627. cmd_isalpha(LONG argc, VALUE *argv)
  628. {
  629.     if(TPLATE1(VTF_NUMBER))
  630.     {
  631.     setnumres(isalpha(ARG1.val_Value.Number));
  632.     }
  633.     return(&RES);
  634. }
  635.  
  636. VALUE *
  637. cmd_isdigit(LONG argc, VALUE *argv)
  638. {
  639.     if(TPLATE1(VTF_NUMBER))
  640.     {
  641.     setnumres(isdigit(ARG1.val_Value.Number));
  642.     }
  643.     return(&RES);
  644. }
  645.  
  646. VALUE *
  647. cmd_isalnum(LONG argc, VALUE *argv)
  648. {
  649.     if(TPLATE1(VTF_NUMBER))
  650.     {
  651.     setnumres(isalnum(ARG1.val_Value.Number));
  652.     }
  653.     return(&RES);
  654. }
  655.  
  656. VALUE *
  657. cmd_isspace(LONG argc, VALUE *argv)
  658. {
  659.     if(TPLATE1(VTF_NUMBER))
  660.     {
  661.     setnumres(isspace(ARG1.val_Value.Number));
  662.     }
  663.     return(&RES);
  664. }
  665.